import { Navigate, createBrowserRouter } from "react-router-dom";
import Homepage from "../pages/Homepage/index.tsx";
import Article from "../pages/Article/index.tsx";
import App from "../App.tsx";
import ChangeSkin from "../pages/ChangeSkin/index.tsx";
import Log from "../pages/Log/index.tsx";
import Login from "../pages/Login/index.tsx";
import Manage from "@/views/Manage/index.tsx";
import BgHomepage from "@/views/Homepage/index.tsx";
import BgArticlePublishing from "@/views/ArticlePublishing/index.tsx";
import BgArticleManagement from "@/views/ArticleManagement/index.tsx";
import BgLog from "@/views/Log/index.tsx";
import BgChangeSkin from "@/views/ChangeSkin/index.tsx";
import AIChat from "@/components/front/AIChat/index.tsx";
import ImageComprehension from "@/components/front/ImageComprehension/index.tsx";

const router = createBrowserRouter([
  {
    path: "/",
    // 重定向到主页
    element: <Navigate to="/homepage" />,
  },
  {
    path: "/",
    element: <App></App>,
    children: [
      {
        path: "/homepage",
        element: <Homepage></Homepage>,
        children: [
          {
            path: "/homepage/chat",
            element: <AIChat></AIChat>,
          },
          {
            path: "/homepage/image",
            element: <ImageComprehension></ImageComprehension>,
          },
        ],
      },
      {
        path: "/article",
        element: <Article></Article>,
      },
      {
        path: "/log",
        element: <Log></Log>,
      },
      {
        path: "/changeSkin",
        element: <ChangeSkin></ChangeSkin>,
      },
      {
        path: "/login",
        element: <Login></Login>,
      },
    ],
  },
  {
    path: "/manage",
    // 重定向到首页
    element: <Navigate to="/manage/homepage" />,
  },
  {
    path: "/manage",
    element: <Manage></Manage>,
    children: [
      {
        path: "/manage/homepage",
        element: <BgHomepage></BgHomepage>,
      },
      {
        path: "/manage/article/publishing",
        element: <BgArticlePublishing></BgArticlePublishing>,
      },
      {
        path: "/manage/article/management",
        element: <BgArticleManagement></BgArticleManagement>,
      },
      {
        path: "/manage/log",
        element: <BgLog></BgLog>,
      },
      {
        path: "/manage/changeSkin",
        element: <BgChangeSkin></BgChangeSkin>,
      },
    ],
  },
]);

export default router;
